<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2008 XBRL International. All Rights Reserved. -->
<?xml-stylesheet type="text/xsl" href="../stylesheets/conformanceFunction.xsl"?>
<testcase
  xmlns="http://xbrl.org/2008/conformance"
  xmlns:reg="http://xbrl.org/2008/registry"
  xmlns:fcn="http://xbrl.org/2008/function"
  xmlns:cfcn="http://xbrl.org/2008/conformance/function"
  xmlns:xbrli="http://www.xbrl.org/2003/instance"
  xmlns:xhtml="http://www.w3.org/1999/xhtml"
  xmlns:xfi="http://www.xbrl.org/2008/function/instance"
  xmlns:xfie="http://www.xbrl.org/2008/function/instance/error"
  xmlns:xqt-err="http://www.w3.org/2005/xqt-errors"
  xmlns:concept="http://xbrl.org/formula/conformance/example" 
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xsi:schemaLocation="
  http://xbrl.org/2008/registry ../schemas/registry.xsd
  http://xbrl.org/2008/function ../schemas/function.xsd
  http://xbrl.org/2008/conformance ../schemas/conformance.xsd
  http://xbrl.org/2008/conformance/function ../schemas/conformanceFunction.xsd
  ">
  <owners>
    <reg:owner id="herm">
      <reg:name>Herm Fischer</reg:name>
      <reg:affiliation>UBMatrix / Mark V Systems</reg:affiliation>
      <reg:email>fischer@markv.com</reg:email>
     <reg:assumedOwnership moment="2008-02-19T00:00:00" />
    </reg:owner>
  </owners>

  <number>80120</number>

  <name>Function test xfi:period</name>

  <documentation>
    <xhtml:p>
      Tests of function xfi:period($item as schema-element(xbrli:item)) as element(xbrli:period)
      </xhtml:p>
  </documentation>

  <reference xlink:type="simple" xlink:href="http://www.xbrl.org/Specification/XF-PWD-2006-12-07.htm#_Toc152670674"/>

  <variation id="V-01">
    <name>Returns correct element for concept whose context is instant</name>
    <documentation>
      <xhtml:p>
      </xhtml:p>
    </documentation>

    <inputs>
      <schema xlink:type="simple" xlink:href="period-tests.xsd"/>
      <instance readMeFirst="true" id="V01" xlink:type="simple" xlink:href="hello-worlds-instance.xml"/>
      <cfcn:call file="V01">
         xfi:period( /xbrli:xbrl/concept:cI[1] )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result instance of element(xbrli:period) and 
         count( $result ) eq 1 and 
         $result is /xbrli:xbrl/xbrli:context[@id eq 'context-earth']/xbrli:period
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-02">
    <name>Period for concept with a start-end duration context</name>
    <documentation>
      <xhtml:p>
      </xhtml:p>
    </documentation>
    <inputs>
      <schema xlink:type="simple" xlink:href="period-tests.xsd"/>
      <instance readMeFirst="true" id="V02" xlink:type="simple" xlink:href="hello-worlds-instance.xml"/>
      <cfcn:call file="V02">
         xfi:period( /xbrli:xbrl/concept:cD[1] )
      </cfcn:call>
    </inputs>
    <outputs>
      <cfcn:test>
         $result instance of element(xbrli:period) and 
         count( $result ) eq 1 and 
         $result is (//xbrli:period)[2]
      </cfcn:test>
    </outputs>
  </variation>

  <variation id="V-05">
    <name>Wrong node to function</name>
    <documentation>
      <xhtml:p>
        XPath-defined error for node type incorrect.
      </xhtml:p>
    </documentation>
    <inputs>
      <schema xlink:type="simple" xlink:href="period-tests.xsd"/>
      <instance readMeFirst="true" id="V05" xlink:type="simple" xlink:href="hello-worlds-instance.xml"/>
      <cfcn:call file="V05">
         xfi:period( /xbrli:xbrl/xbrli:context[2] )
      </cfcn:call>
    </inputs>
    <outputs>
      <error>xqt-err:XPTY0004</error>
    </outputs>
  </variation>  

  <variation id="V-06">
    <name>A sequence of items as argument</name>
    <documentation>
      <xhtml:p>
        XPath-defined error for node type incorrect arity of argument.
      </xhtml:p>
    </documentation>
    <inputs>
      <schema xlink:type="simple" xlink:href="period-tests.xsd"/>
      <instance readMeFirst="true" id="V06" xlink:type="simple" xlink:href="hello-worlds-instance.xml"/>
      <cfcn:call file="V06">
         xfi:period( /xbrli:xbrl/concept:cD )
      </cfcn:call>
    </inputs>
    <outputs>
      <error>xqt-err:XPTY0004</error>
    </outputs>
  </variation>

  <revisions>
    <reg:revision on="2008-02-19T00:00:00" by="herm">
      <xhtml:p>
        Created the test case.
      </xhtml:p>
    </reg:revision>
  </revisions>

</testcase>
